<%-- 
    Document   : houses
    Created on : 21.11.2012, 12:11:56
    Author     : Q.90
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page import="java.util.Locale" %>

<fmt:bundle basename="StripesResources" /> 
<fmt:message key='admin.housesTitle' var="title"/>
<s:layout-render name="adminlayout.jsp" nadpis="${title}">
    <s:layout-component name="telo">
        <s:useActionBean beanclass="cz.muni.fi.pa165.hauntedhouses.web.HousesActionBean" var="actionBean"/>
        <center>
            <c:choose>
                <c:when test="${fn:length(actionBean.houses) == 0}">
                    <div><font style="color: red;" ><fmt:message key="menu.nohouses"/></font></div><br /><br />
                </c:when>
                <c:otherwise>
                    <table class="zakladni">
                        <tr>
                            <th>ID</th>
                            <th><fmt:message key="admin.houseName"/></th>
                            <th><fmt:message key="admin.houseAddress"/></th>
                            <th><fmt:message key="admin.humanCapacity"/></th>
                            <th><fmt:message key="admin.houseFullness"/></th>
                            <th><fmt:message key="admin.ghostCapacity"/></th>
                            <th><fmt:message key="admin.houseHistory"/></th>
                            <th></th>
                            <th></th>
                            <th></th>
                        </tr>
                        <c:forEach items="${actionBean.houses}" var="house">
                            <tr>
                                <td>${house.id}</td>

                                <td><c:out value="${house.name}"/></td>
                                <td><c:out value="${house.address}"/></td>
                                <td><c:out value="${house.humanCapacity}"/></td>
                                <td><c:out value="${house.humans.size()}"/></td>
                                <td><c:out value="${house.ghostCapacity}"/></td>
                                <td><c:out value="${house.history}"/></td>
                                <c:choose>
                                    <c:when test="${fn:length(house.humans) == 0}">
                                        <td><s:link beanclass="cz.muni.fi.pa165.hauntedhouses.web.HousesActionBean" event="editHumans"><s:param name="house.id" value="${house.id}"/><fmt:message key="admin.addHuman"/></s:link> </td>                  
                                    </c:when>
                                    <c:otherwise>
                                        <td><s:link beanclass="cz.muni.fi.pa165.hauntedhouses.web.HousesActionBean" event="editHumans"><s:param name="house.id" value="${house.id}"/><fmt:message key="admin.viewHumans"/></s:link></td>
                                    </c:otherwise>
                                </c:choose>
                                <td><s:link beanclass="cz.muni.fi.pa165.hauntedhouses.web.HousesActionBean" event="edit"><s:param name="house.id" value="${house.id}"/><fmt:message key="admin.edit"/></s:link> </td>
                                <td><s:link beanclass="cz.muni.fi.pa165.hauntedhouses.web.HousesActionBean" event="delete"><s:param name="house.id" value="${house.id}"/><fmt:message key="admin.delete"/></s:link> </td>
                                </tr>
                        </c:forEach>
                    </table>
                </c:otherwise>
            </c:choose>
            <s:form style="width:400px" beanclass="cz.muni.fi.pa165.hauntedhouses.web.HousesActionBean">
                <br /><fieldset><legend><fmt:message key="admin.newHouse"/></legend>
                    <%@include file="houseForm.jsp"%>
                    <s:submit name="add"><fmt:message key="admin.newHouse"/></s:submit>
                    </fieldset>
            </s:form>
        </center>
    </s:layout-component>
</s:layout-render>
